require 'gtk2'

# Zerenity provides a number of simple graphical dialogs.
#
# Global Options:
# * :title - The text displayed in the title bar
# * :text - The text that will be displayed in the dialog
module Zerenity
  CLICKED = "clicked"
  class Base # :nodoc:
    def self.check(options)
    end

    def self.build(vbox,options)
      options[:ok_button] = Gtk::Button.new(Gtk::Stock::OK)
      options[:cancel_button] = Gtk::Button.new(Gtk::Stock::CANCEL)
    end
    
    def self.run(options)
      self.check(options)
      Gtk.init
      dialog = Gtk::Dialog.new(options[:title])
      self.build(dialog.vbox,options)
      result = nil
     
      options[:cancel_button].signal_connect(CLICKED) do
        dialog.destroy
        Gtk.main_quit
      end
      dialog.action_area.add(options[:cancel_button])
      options[:ok_button].signal_connect(CLICKED) do
        result = self.retrieve_selection(dialog.vbox,options)
        dialog.destroy
        Gtk.main_quit
      end
      dialog.action_area.add(options[:ok_button])
      dialog.show_all
      Gtk.main
      return result 
    end

    def self.retrieve_selection(vbox,options)
    end
  end
end
